const express = require('express');
const port = 8000;
const app = express();

const multer = require('multer');
const multerObj = multer({
    dest: './static'
});
app.use(multerObj.any());

app.use(express.static('./'));


// 使能获取post参数
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

const cookieParser = require('cookie-parser');
app.use(cookieParser('asd123hjk,.1/3jd*Y@HJ!'));


const session = require('express-session');

const { store } = require('./redis');

app.use(session({
    store,
    saveUninitialized: true,
    secret: 'asd123hjk,.1/3jd*Y@HJ!',
    resave: false,
    rolling: true,
    cookie: {
        maxAge: 7 * 24 * 60 * 60 * 1000
    }
}));



// 监听socket,需要使用http创建Server实例
const http = require('http').createServer(app);
require('./socket')(http);



app.use('/user', require('./router/user'));
app.use('/check', require('./router/check'));
app.use('/update', require('./router/update'));
app.use('/group', require('./router/group'));
app.use('/search', require('./router/search'));
app.use('/sysmsg', require('./router/sysmessage'));

http.listen(port, () => console.log(`端口${port}开启`));

